(define-module (rain midori)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (gnu packages)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages gstreamer)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages webkit)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages pkg-config)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system cmake)
  )

(define-public midori
  (package
    (name "midori")
    (version "0.5.11")
    (source (origin
              (method url-fetch)
	      (uri (string-append "https://launchpad.net/midori/trunk/"
				  version
				  "/+download/midori-" version ".tar.bz2"))
              (sha256
               (base32
                "0gcwqkcyliqz10i33ww3wl02mmfnl7jzl2d493l4l53ipsb1l6cn"))))
    (build-system cmake-build-system)
    (arguments
     '(#:tests? #f ;; sadly they fail
       #:phases
       (alist-cons-after
	'install 'wrap-programs
	(lambda* (#:key inputs outputs #:allow-other-keys)
	  (let ((out (assoc-ref outputs "out")))
	    (wrap-program "midori"
	      `("LD_LIBRARY_PATH" ":" prefix (,(string-append out "lib64"))))))
	(modify-phases %standard-phases
	  (delete 'validate-runpath))) ;; seems bad to remove it
       #:configure-flags (list "-DUSE_ZEITGEIST=off"
			       "-DCMAKE_INSTALL_LIBDIR=lib")))
       ;;(string-append "-DCMAKE_INSTALL_RPATH="
         ;;                                     (assoc-ref %outputs "out")
           ;;                                   "/lib:"
             ;;                                 (assoc-ref %outputs "out")
               ;;                               "/lib64"))))
    (native-inputs
     `(("pkg-config" ,pkg-config)
       ("vala" ,vala)
       ("gtk2" ,gtk+-2)
       ("webkitgtk/gtk+-2" ,webkitgtk/gtk+-2)
       ("gobject-introspection" ,gobject-introspection)
       ("glib" ,glib "bin")
       ("libxml2" ,libxml2)
       ("sqlite" ,sqlite)
       ("gcr" ,gcr)
       ("libsoup" ,libsoup)
       ("gettext" ,gnu-gettext)
       ("intltool" ,intltool)
       ("librsvg" ,librsvg)

       ("gstreamer" ,gstreamer)
       ("gst-plugins-base" ,gst-plugins-base)
       ("gst-plugins-good" ,gst-plugins-good)
       ;("gst-plugins-bad" ,gst-plugins-bad)
       ("gst-plugins-ugly" ,gst-plugins-ugly)))
    (propagated-inputs
     `(("glib-networking" ,glib-networking) ;; not working yet? installed seperately
       ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)

       ("gstreamer" ,gstreamer)
       ("gst-plugins-base" ,gst-plugins-base)
       ("gst-plugins-good" ,gst-plugins-good)
       ;("gst-plugins-bad" ,gst-plugins-bad)
       ("gst-plugins-ugly" ,gst-plugins-ugly)

       ))
    (home-page "http://www.midori-browser.org/")
    (synopsis "Midori Web Browser")
    (description
     "Midori is a lightweight, fast, and free web browser. It aligns well with the Xfce philosophy of making the most out of available resources.")
    (license license:lgpl2.1+)))
